import Vue from 'vue'
import Vuex from 'vuex'

// 引入插件
import createPersistedState from "vuex-persistedstate";
import * as CooKies from "js-cookie"

// 导入模块
import login from "@/store/modules/login/index.js"
import user from "@/store/modules/user/index.js"

Vue.use(Vuex)

export default new Vuex.Store({
   
  modules:{
    login,
    user
  },
  plugins:[
    createPersistedState({
       // 存储方式：localStorage、sessionStorage、cookies  默认: localStorage
			storage: window.localStorage,
      supportCircular: true, // 支持循环引用
      asyncStorage: false,
      key:"erabbit-client-pc-store",
      paths:["login.userList","login.token","user.userInfo"],
  
      // 节流，每500毫秒保存一次
      // throttle: 500,
      

      // storage:{
      //   getItem:key=>CooKies.get("key"),
      //   setItem:(key,value)=>CooKies.set(key,value,{expires:7}),
      //   removeItem:key=>CooKies.remove(key)
      // }
    }),

  ]
})
